package com.bsj.power.system.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.bsj.power.common.config.global.JsonResult;
import com.bsj.power.common.def.dto.sys.SystemConfigDTO;
import com.bsj.power.common.def.entity.sys.SystemConfig;
import com.bsj.power.system.service.SystemConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author yinhao
 * @version 1.0
 * @description 系统规则配置
 * @date 2024/8/26
 */
@Slf4j
@RestController
@RequestMapping("/system/config")
//@SaCheckPermission("/master/system/config")
public class SystemConfigController {

    @Autowired
    private SystemConfigService systemConfigService;

    /**
     * 修改或新增配置规则
     * @param dto
     * @return
     */
    @PostMapping(value = "/addAndUpdateConf")
    public JsonResult<Integer> addAndUpdateConf(@Valid @RequestBody SystemConfigDTO dto) {
        return JsonResult.success(systemConfigService.addAndUpdateConf(dto));
    }

    /**
     * 获取规则信息
     * @return
     */
    @GetMapping(value = "/queryConf")
    public JsonResult<SystemConfig> queryConf() {
        return JsonResult.success(systemConfigService.queryConf());
    }
}
